package com.atguigu.day20.syn01.s3;

//todo 翠花线程
public class ChThread extends Thread {

    private Account account;

    public void setAccount(Account account) {
        this.account = account;
    }

    @Override
    public void run() {
       // synchronized (account) {
        synchronized ("ABC") {
            //1.余额校验
            if (account.money >= 1500) {
                //2.满足 取钱成功
                account.withDraw(1500);
                System.out.println(this.getName() + " 取钱成功,余额是" + account.money + "元");
            } else {
                //3.不满足 取钱失败
                System.out.println(this.getName() + " 取钱失败 余额不足,余额是" + account.money + "元");
            }
        }
    }
}
